import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { DescItem } from '/@/components/Description/index';

export const columns: BasicColumn[] = [
  {
    title: '用户名称',
    dataIndex: 'userName',
    width: 120,
    slot: 'account',
    align: 'left',
  },
  {
    title: '客户端',
    dataIndex: 'clientId',
    width: 110,
  },
  {
    title: '登录IP',
    dataIndex: 'ip',
    width: 140,
  },
  {
    title: '登录地点',
    dataIndex: 'location',
    width: 150,
  },
  {
    title: '浏览器',
    dataIndex: 'browser',
    width: 100,
  },
  {
    title: '操作系统',
    dataIndex: 'os',
    width: 100,
  },

  {
    title: '状态',
    dataIndex: 'status',
    width: 60,
    customRender: ({ text }) => {
      const color = text == '1' ? 'red' : text == '0'? 'green': 'gray';
      return render.renderTag(render.renderDict(text, 'login_status'),color)
    },
  },
  {
    title: '操作信息',
    dataIndex: 'msg',
    width: 120,
  },
  {
    title: '登录日期',
    dataIndex: 'loginTime',
    width: 150,
  },
];

export const formDetailSchema : DescItem[] = [
  {
    field: 'userName',
    label: '用户名称'
  },
  {
    field: 'ip',
    label: '登录IP'
  },
  {
    field: 'location',
    label: '登录地点'
  },
  {
    field: 'browser', 
    label: '浏览器'
  },
  {
    field: 'os',
    label: '操作系统',
  },
  {
    field: 'status',
    label: '状态',
    render: (curVal, data) => {
      const color = curVal == '1' ? 'red' : curVal == '0'? 'green': 'gray';
      return render.renderTag(render.renderDict(curVal, 'login_status'),color)
    },
  },
  {
    field: 'msg',
    label: '操作信息',
  },
  {
    field: 'loginTime',
    label: '登录日期'
  },
  
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '用户名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'status',
    label: '登录状态',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'login_status',
      stringToNumber: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'loginTime',
    component: 'RangePicker',
    label: '登录时间',
    componentProps: {
      valueType: 'Date',
    },
    colProps: {
      span: 8,
    },
  },
];